package com.tianji.learning.mq.listener;

import com.tianji.api.dto.trade.OrderBasicDTO;
import com.tianji.common.constants.MqConstants;
import com.tianji.common.utils.CollUtils;
import com.tianji.learning.domain.po.LearningRecord;
import com.tianji.learning.service.impl.LearningRecordServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 学习记录监听器
 * </p>
 *
 * @author taohongrun
 * @since 2025/2/5
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class LessonRecordListener {
    private final LearningRecordServiceImpl learningRecordService;

    @RabbitListener(bindings = @QueueBinding(value = @Queue("learning.record.commit.queue")
            ,exchange = @Exchange(value = MqConstants.Exchange.LEARNING_COMMIT_DELAY,type = ExchangeTypes.DIRECT,delayed = "true")
            ,key = MqConstants.Key.COMMIT_DELAY_KEY))
    public void listenLessonPay(LearningRecord learningRecord){
        log.info("延迟任务提交学习记录交换机收到信息");
      learningRecordService.handleCommitDelayTask(learningRecord);
    }

}
